<%include("/common/_meta.html"){} %>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/jslib/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb">
<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 权限管理 <span class="c-gray en">&gt;</span> 用户管理 
<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
	<div class="text-c">
		<input type="text" class="input-text" style="width:250px">
		<button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l"><a href="javascript:;" onclick="editUser(null)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a></span>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
	    <table id="dataTable"></table>
	</div>
</div>
<script type="text/javascript" src="/static/jslib/jquery-2.1.1.js"></script>  
<script type="text/javascript" src="/static/jslib/layer/2.1/layer.js"></script> 
<script type="text/javascript" src="/static/jslib/My97DatePicker/WdatePicker.js"></script> 
<script src="/static/jslib/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/static/jslib/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/static/jslib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/static/jslib/base_list.js"></script>
<script src="/static/jslib/common.js"></script>
<script type="text/javascript">
var dataUrl = "/perm/user/getUserList.html";
var dataColumns = [ {
    field: 'loginName',
    title: '登录名',
}, {
    field: 'email',
    title: '邮箱',
}, {
    field: 'type',
    title: '用户类型',
}, {
    field: 'status',
    title: '状态',
    align: 'center'
}, {
    field: 'crTime',
    title: '创建时间',
    align: 'center',
    formatter: function (value, row, index) {
        return formatDate(row.crTime);
    }
}, {
    title: '操作',
    align: 'center',
    formatter: function (value, row, index) {
        var id = row.id;
        return '<a class="btn btn-xs btn-warning" onclick="editUser(' + "'" + id + "'" + ')"><i class="fa fa-pencil"></i>编辑</a> '
                <!-- 此处按钮级别权限控制，目前只有 admin 拥有该权限！ -->
        		<%if(SSOPermission.isActionable("10010")){%>	
                + '<a class="btn btn-xs btn-danger" onclick="delUser(' + "'" + id + "'" + ')"><i class="fa fa-remove"></i>删除</a>'
                <%}%>;

    }
}
];
function dataQueryParams(params) {
    return {
        _size: params.limit,  //页面大小
        _index: params.offset, //页码
    };
}

function delUser(userId) {
    //询问框
    layer.confirm('确定删除吗？', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            type: "POST",
            url: "/perm/user/delUser/" + userId,
            datatype: "text",
            success: function (data) {
                if(data == 'true'){
                    $('#dataTable').bootstrapTable('refresh',{url:dataUrl});
                }
                layer.closeAll();
            }
        });
    }, function () {
        return;
    });
}

function editUser(id){
	var title = "新增用户";
	var url = "/perm/user/edit.html";
	if(id!=null){
		title = "编辑用户";
		url = url + "?id=" + id;
	}
	layer.open({
	    type: 2,
	    title: title,
	    shadeClose: true,
	    shade: 0.8,
	    area: ['600px', '430px'],
	    fix: false,
	    maxmin: true,
	    content: url
	});
}
</script>
</body>
</html>